package core

// PktRecordHeap packet record heap
type PktRecordHeap []*PktRecord

func (h *PktRecordHeap) Len() int { return len(*h) }
func (h *PktRecordHeap) Less(i, j int) bool {
	return (*h)[i].TxTs < (*h)[j].TxTs
}
func (h *PktRecordHeap) Swap(i, j int) { (*h)[i], (*h)[j] = (*h)[j], (*h)[i] }

func (h *PktRecordHeap) Push(b any) {
	*h = append(*h, b.(*PktRecord))
}

func (h *PktRecordHeap) Pop() any {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}
